<?php 
session_start();
if(!empty($_GET['userid'])){	
	$id = $_GET['userid'];
}
$db = include('../Application/Common/Conf/config.php');	
					
				$host =  $db['DB_HOST'];
				$port =  $db['DB_PORT'];
				$dbname =  $db['DB_NAME'];
				$user =  $db['DB_USER'];
				$psw =  $db['DB_PWD'];
				$orderId = $_SESSION['orderid'];
				$dbconn = pg_connect("host=$host port=$port dbname=$dbname user=$user password=$psw");	
				if($orderId){
				if($dbconn){					
					$sql = "select nstate,nuserid from tbusercashflow where corderid='$orderId';";
					$infor = pg_query($dbconn,$sql);
					$infor = pg_fetch_assoc($infor);
					
					if($infor['nstate']==1){
						$_SESSION['orderstatus'] = $orderId."yes";
						header("Location: paysuccess.php?userid=$id"); 
						exit;  
					}else{	
						$_SESSION['orderstatus'] = $orderId."no";
						header("Location: payfalied.php?userid=$id"); 
						exit;
					}
				}
				}else{
					echo '不存在此订单号';
				}
		

		

?>